import os

# 获取系统进程的py脚本
if __name__ == '__main__':
    os.system("ps aux | awk '{print $11}' | grep -v ] > origin.txt")
    processes = []
    with open("origin.txt", 'r') as fp:
        lines = fp.readlines()
        del(lines[0])
        for line in lines:
            line = line[:-1]
            line = line[::-1]
            index = line.find('/')
            if(index == -1):
                process = line[::-1]
            else:
                process = line[:index]
                process = process[::-1]
            if(process[-1]==":"):
                process = process[:-1]
            if(process[0]=="("):
                process = "'" + process + "'"
            if(len(process)>15):
                process = process[:15]
            processes.append(process)
    os.remove("origin.txt")
    processes.remove('sh')
    processes.remove('awk')
    processes.remove('ps')
    processes.remove('grep')
    while "bash" in processes:
        processes.remove("bash")
    while "python3" in processes:
        processes.remove("python3")
    print(processes)

